Skip to content

Conversation

@carmocca
Copy link
Contributor

@carmocca carmocca commented May 31, 2021

What does this PR do?

Includes part of the changes to properly support self.log('foo', {...}):

  • Apply to collection sync
  • Check for None log values
  • Apply to collection reductions

Documentation and tests for this feature will come in later PRs

Part of #7631

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@carmocca carmocca added the feature Is an improvement or enhancement label May 31, 2021
@carmocca carmocca added this to the v1.4 milestone May 31, 2021
@carmocca carmocca self-assigned this May 31, 2021
@carmocca carmocca changed the title Enh/extend support log collection Extend support for logging a collection May 31, 2021
@codecov
Copy link

codecov bot commented May 31, 2021

Codecov Report

Merging #7771 (1da392d) into master (d47173b) will decrease coverage by 0%.
The diff coverage is 83%.

@@          Coverage Diff           @@
##           master   #7771   +/-   ##
======================================
- Coverage      93%     92%   -0%     
======================================
  Files         199     199           
  Lines       12985   12979    -6     
======================================
- Hits        12018   11978   -40     
- Misses        967    1001   +34     

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general. There are a few typing things that are unrelated to this PR, but since it's a rather small one, I think it should be fine.

@Borda Borda added the ready PRs ready to be merged label May 31, 2021
@mergify mergify bot removed the has conflicts label May 31, 2021
@carmocca carmocca enabled auto-merge (squash) May 31, 2021 17:05
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@carmocca carmocca merged commit 1dd61e4 into master Jun 1, 2021
@carmocca carmocca deleted the enh/extend-support-log-collection branch June 1, 2021 11:51
def log_dict(
self,
dictionary: dict,
dictionary: Dict[str, _METRIC_COLLECTION],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type here is interesting.

If this is read-only, let's use Mapping[str, _METRIC_COLLECTION] which is covarient with the value type of the key (meaning that Mapping[str, torch.Tensor] and Mapping[str, Metric]`) are both subtypes, and will validate type checking.

Since Dict implies mutability (eg, the function might mutate the dictionary), the type checker defines it as invariant. As such, Dict[str, torch.Tensor] is NOT a valid type to pass to to a function accepting Dict[str, Union[torch.Tensor, Metric]]). See here for discussion: python/mypy#2300 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! I did not know that.

Feel free to open a patch with the change. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a minor type-only change, sent it out with #7851.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Is an improvement or enhancement ready PRs ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants